<?php
/**
 * 用户中心SDK
 * 
 * @author ShuangYa
 * @package EUser
 * @category SDK
 * @copyright Copyright (c) 2015-2016 ShuangYa
 * @link  http://lab.sylingd.com/go.php?name=euser&type=license
 */

class EUser_http {
	protected $baseUrl;
	public function __construct($config) {
		$this->baseUrl = $config['server']['url'];
	}
	public function get($router, $data, $sign) {
		$url = $this->baseUrl . $router;
		$ch = curl_init();
		curl_setopt_array($ch, [
			CURLOPT_URL => $url,
			CURLOPT_HEADER => FALSE,
			CURLOPT_POST => TRUE,
			CURLOPT_POSTFIELDS => json_encode($data),
			CURLOPT_RETURNTRANSFER => TRUE,
			CURLOPT_HTTPHEADER => ['X-Method: SDK-HTTP', 'X-Sign: ' . $sign],
			CURLOPT_TIMEOUT => 3
		]);
		$r = curl_exec($ch);
		curl_close($ch);
		return json_decode($r, 1);
	}
	public function __destruct() {
	}
}